package com.graduate.common.entity;

import java.util.Map;

/**
 * 最后返回给前端的结果对象
 * @author bwzfy
 * @create 2021/5/11
 **/
public class Result<T> {

    // 返回的状态码
    private Integer code;

    // 返回的状态信息
    private Map<String, String> info;

    // 最后返回的数据
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Map<String, String> getInfo() {
        return info;
    }

    public void setInfo(Map<String, String> info) {
        this.info = info;
    }

    public T getData() {
        return data;
    }

    public Result<T> failure() {
        // 如果失败就把状态码设置成500
        this.code = 500;
        return this;
    }

    public Result<T> success() {
        //如果最后成就把状态码设置成200
        this.code = 200;
        return this;
    }

    public void setData(T data) {
        this.data = data;
    }
}
